home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / c.dxr / 00010_CAnimator.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  1.5 KB  |  47 lines

  1. property ancestor, pPathFunctionData, pPathData, pCurrentLoc, pStartLoc, pRefName
  2.  
  3. on birth me, arguments
  4.   set the ancestor of me to birth(script "Animator", arguments)
  5.   set the pPathFunctionData of me to the pathData of arguments
  6.   set pStartLoc to the location of arguments
  7.   set pRefName to the RefName of arguments
  8.   set pCurrentLoc to pStartLoc
  9.   return me
  10. end
  11.  
  12. on moveSprite me
  13.   set theResult to GenLoc(me)
  14.   set the pCurrentLoc of me to theResult
  15.   set the loc of sprite the pChannel of me to the pCurrentLoc of me
  16. end
  17.  
  18. on GenLoc me
  19.   set OBJref to the pRefName of me
  20.   set thisList to getaProp(getaProp(gObjects, OBJref), #graphList)
  21.   if voidp(thisList) then
  22.     exit
  23.   end if
  24.   if voidp(getaProp(getaProp(gObjects, OBJref), #animator)) then
  25.     set startloc to getaProp(getaProp(gObjects, OBJref), #onloc)
  26.   else
  27.     set startloc to the pCurrentLoc of getaProp(getaProp(gObjects, OBJref), #animator)
  28.   end if
  29.   set V to the locV of startloc
  30.   set H to the locH of startloc + getaProp(thisList, #frameHStep)
  31.   if H > getaProp(thisList, #maxHLoc) then
  32.     set H to getaProp(thisList, #minHLoc)
  33.   end if
  34.   if random(2) = 1 then
  35.     set V to V + random(getaProp(thisList, #maxRandomInt))
  36.     if V > getaProp(thisList, #maxVLoc) then
  37.       set V to V - random(getaProp(thisList, #maxRandomInt))
  38.     end if
  39.   else
  40.     set V to V - random(getaProp(thisList, #maxRandomInt))
  41.     if V < getaProp(thisList, #minVLoc) then
  42.       set V to V + random(getaProp(thisList, #maxRandomInt))
  43.     end if
  44.   end if
  45.   return point(H, V)
  46. end
  47.